<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        window.onload=function(){
            //绑定按钮事件
            document.querySelector('[type="button"]').onclick=function(event){
                //获取输入的搜索内容
                var search=event.target.previousElementSibling.value;
                //判断是否为空字符串
                if(search.length<1){
                    alert('请输入搜索内容!');
                }else{
                    //将搜索内容传递到第3个页面
                    location.href='./03-HomeWork.html?search='+search;
                }
            }
        }
    </script>
</head>
<body>
    <input type="text" name="search" id="search">
    <input type="button" value="搜索">
</body>
</html>